﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

using H2.NET.Controls;
using H2.NET.Business;
using H2.NET.Data.Common;

using System.IO;
using H2.NET.Data.Exceller;

namespace H2.NET.Web.Pages.SPM
{
    public partial class Old_New_Formula : TaskPage
    {
        #region 属性 Public

        private bool IsLoaded
        {
            get
            {
                return ViewState["IsLoaded"] == null ? false : (bool)ViewState["IsLoaded"];
            }
            set { ViewState["IsLoaded"] = value; }
        }
        private bool Status
        {
            get
            {
                return ViewState["Status"] == null ? false : (bool)ViewState["Status"];
            }
            set { ViewState["Status"] = value; }
        }
        public string Key
        {
            get
            {
                return ViewState["Key"] == null ? "" : (string)ViewState["Key"];

            }
            set { ViewState["Key"] = value; }
        }
        private string[] P_Plant
        {
            get
            {
                if (StoreAPI["P_Plant~" + Key] == null)
                {
                    IList<m_Plant> dlts = (m_Plant.status == 1 & m_Plant.categary == "P").List<m_Plant>();
                    string[] p_plant = new string[dlts.Count + 1];

                    p_plant[0] = "";
                    for (int i = 0; i < dlts.Count; i++)
                    {
                        p_plant[i + 1] = dlts[i].PlantName;
                    }

                    StoreAPI["P_Plant~" + Key] = p_plant;
                }

                return (string[])StoreAPI["P_Plant~" + Key];
            }
        }
        #endregion
        #region 事件 Page_Load(页面加载)
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {

            bool flg =  TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit  ? true : false;
            this.gv_Formula_Change.DynamicColumn.Add(new BoundColumn2("00", "Fini Sap Code", BoundColumnType2.TextBox, 100, Align.Left, flg, "Fini_Sap_Code", InputType.None, null));
            gv_Formula_Change.DynamicColumn.Add(new BoundColumn2("01", "Fini Bpcs Code", BoundColumnType2.TextBox, 200, Align.Left, flg, "Fini_Bpcs_Code", InputType.None, null));
            gv_Formula_Change.DynamicColumn.Add(new BoundColumn2("02", "Plant", BoundColumnType2.DropDownList, 60, Align.Left, flg, "Plant", InputType.None, P_Plant));
            gv_Formula_Change.DynamicColumn.Add(new BoundColumn2("03", "Old Fini Sap Code", BoundColumnType2.TextBox, 70, Align.Left, flg, "Old_Fini_Sap_Code", InputType.None, null));
            gv_Formula_Change.DynamicColumn.Add(new BoundColumn2("04", "Old Fini Bpcs Code", BoundColumnType2.TextBox, 60, Align.Left, flg, "Old_Fini_Bpcs_Code", InputType.None, null));
            gv_Formula_Change.DynamicColumn.Add(new BoundColumn2("05", "New Fini Sap Code", BoundColumnType2.TextBox, 70, Align.Left, flg, "New_Fini_Sap_Code", InputType.None, null));
            gv_Formula_Change.DynamicColumn.Add(new BoundColumn2("06", "New Fini Bpcs Code", BoundColumnType2.TextBox, 160, Align.Left, flg, "New_Fini_Bpcs_Code", InputType.None, null));
            gv_Formula_Change.DynamicColumn.Add(new BoundColumn2("07", "Density", BoundColumnType2.TextBox, 100, Align.Left, flg, "Density", InputType.None, null));
            //gv_Formula_Change.DynamicColumn.Add(new BoundColumn2("08", "Vendor Code", BoundColumnType2.TextBox, 80, Align.Left, false, "Vendor_Code", InputType.None, null));

            if (!Page.IsPostBack)
            {
                INFO.Text = string.Format("<br/>表单正在被同事“{0}”抢占处理，拒绝提交！", RobUser);
                INFO.Visible = IsOverFlow;
                InitControls();
                //InitDropDownList();

                #region 发起步骤
                if (TaskAPI.IsInitiate)
                {

                }
                #endregion
                #region 审批环节
                else
                {
                    #region 加载数据并显示
                    mdc_spm_Formula_Change mdc_spm_Formula = (mdc_spm_Formula_Change.process == TaskAPI.Process & mdc_spm_Formula_Change.incident == TaskAPI.Incident).ListFirst<mdc_spm_Formula_Change>();
                    if (mdc_spm_Formula != null)
                    {
                        ApplicationNo.Text = mdc_spm_Formula.ApplicationNo;
                        DrpPriority.SelectedValue = mdc_spm_Formula.DrpPriority;
                        DMO_DrpPriority.SelectedValue = mdc_spm_Formula.DMO_DrpPriority;
                    }
                    #endregion

                    #region 审批项初始化
                    switch (TaskAPI.Step)
                    {
                        case "DMO Approve":
                        case "DMO Maintain":
                        case "DMO Check":
                        case "DMO Provide List":
                        case "SH Planning":
                        case "GZ Planning":
                        case "LF Planning":
                        case "LAM Provide List":
                            Assessment1.Option.Add(new t_AssessmentOption("Finish", "1", true));
                            Assessment1.Option.Add(new t_AssessmentOption("Return", "2", false));
                            break;

                    }
                    #endregion
                }
                #endregion
                #region 设置控件禁启用
                bool flg11 = ((TaskAPI.IsBeginStep) && TaskAPI.IsAllowSubmit) ? true : false;
                SetEnable(TaskAPI.IsInitiate && TaskAPI.IsAllowSubmit, DrpPriority);
                Assessment1.Enable = TaskAPI.IsAllowSubmit;
                SetEnable(TaskAPI.Step == "DMO Approve" | TaskAPI.Step == "DMO Maintain" | TaskAPI.Step == "DMO Check", DMO_DrpPriority);
                SetVisible(TaskAPI.Step == "DMO Approve" | TaskAPI.Step == "DMO Maintain" | TaskAPI.Step == "DMO Check", P_DMO);
                SetEnable(TaskAPI.Step == "DMO Maintain", SAP_Code);
                SetVisible(flg11, Add, Delete);
                SetVisible(TaskAPI.IsAllowSubmit, Send, Split);
                Attachment1.AllowDelete = flg11;
                Attachment1.AllowUpload = flg11;
                InitTabs();
                //UsersChoose1.MDCActions = Actions.SelectedValue;
                #endregion
            }
        }

        public void InitControls()
        {

            gv_Formula_Change.Key = Key;
            #region 发起步骤
            if (TaskAPI.IsInitiate)
            {
                List<mdc_spm_Formula_Change> mdc_spm_Formula = new List<mdc_spm_Formula_Change>();
                for (int i = 0; i < 5; i++)
                {
                    mdc_spm_Formula.Add(new mdc_spm_Formula_Change());
                    //sales_1_s[i].ID = (i + 1).ToString();
                }
                gv_Formula_Change.DataSource = mdc_spm_Formula;
            }
            #endregion

            #region 审批环节
            else
            {
                IList<mdc_spm_Formula_Change> mdc_spm_Formula = (mdc_spm_Formula_Change.process == TaskAPI.Process & mdc_spm_Formula_Change.incident == TaskAPI.Incident).List<mdc_spm_Formula_Change>();
                if (mdc_spm_Formula.Count == 0)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        mdc_spm_Formula.Add(new mdc_spm_Formula_Change());
                        //sales_1_s[i].ID = (i + 1).ToString();
                    }
                }
                gv_Formula_Change.DataSource = mdc_spm_Formula;

            }
            #endregion
 
        }
        #endregion
        //protected override void OnLoad(EventArgs e)
        //{
        //    InitControls();
        //    base.OnLoad(e);
        //}
 

        #region 事件 Send
        protected void Send_Click(object sender, EventArgs e)
        {

            try
            {
                #region 数据验证
                if ((TaskAPI.IsBeginStep || TaskAPI.Step == "DMO Provide List") && TaskAPI.IsAllowSubmit) // 如果是退回的情况，不存在验证
                {
                    List<string> vald_s = new List<string>();
                    if (TaskAPI.Step == "DMO Provide List")
                    {
                        vald_s.AddRange(UsersChoose1.DataValidation());
                    }
                    else
                    {
                        vald_s.AddRange(DataValidation());
                    }
                    if (vald_s.Count > 0)
                    {
                        Anthem.Manager.AddScriptForClientSideEval(string.Format("ShowMessage(\"{0}\", {1});", CombineMessage(vald_s), vald_s.Count));
                        return;
                    }

                }
                #endregion

                #region 引擎传值
                if (TaskAPI.IsBeginStep)
                {
                    if (TaskAPI.IsInitiate && TaskAPI.IsAllowSubmit)
                    {
                        ApplicationNo.Text = Util.GenerateSequence(((object[])TaskAPI["PrefixNo"])[0].ToString() + "-" + System.DateTime.Now.ToString("yyMM"), "", 4);
                        TaskAPI.UserName = UserAPI.UserName;
                        TaskAPI["ApplicationNo"] = ApplicationNo.Text;
                        TaskAPI["ApplicatorName"] = UserAPI.UserFullName;
                        TaskAPI["Applicator"] = UserAPI.UserName;
                        TaskAPI["Time"] = System.DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                        TaskAPI["ApplicatorEmail"] = UserAPI.Mail;
                        TaskAPI["Department"] = UserAPI.Department;
                        TaskAPI["ServerName"] = Util.AppSettings("ServerName");
                    }

                    TaskAPI.Summary = ApplicationNo.Text;
                    TaskAPI["DrpPriority"] = DrpPriority.SelectedItem.Text;
                    //TaskAPI["Actions"] = VD_Category.SelectedValue;
                    TaskAPI["Remark_by_Initiator"] = Assessment1.Assessment.Remark;
                    SortedList<string, string> tar = new SortedList<string, string>();
                    IList<mdc_Recipient> srcs = (mdc_Recipient.process == TaskAPI.Process
                                                  & (mdc_Recipient.distribute == "*")
                                                  & mdc_Recipient.status == 1).List<mdc_Recipient>();

                    foreach (mdc_Recipient src in srcs)
                    {
                        if (!tar.ContainsKey(src.Step))
                        {
                            tar.Add(src.Step, src.Recipient);
                            continue;
                        }

                        if (tar.Values[tar.IndexOfKey(src.Step)].Contains(src.Recipient))
                        {
                            continue;
                        }

                        tar[src.Step] = tar.Values[tar.IndexOfKey(src.Step)] + "," + src.Recipient;
                    }

                    //步骤处理人赋值
                    for (int i = 0; i < tar.Keys.Count; i++)
                    {
                        TaskAPI["R_" + tar.Keys[i].Replace(" ", "_")] = tar.Values[i].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    }

                #endregion


                }
                else
                {
                    TaskAPI["ApproveResult"] = Assessment1.Assessment.Opinion;
                    TaskAPI["TaskID"] = TaskAPI.TaskID;
                }
 



                #region 提交步骤
                bool flg = false;
                Storage.TransactionExecute(o =>
                {
                    #region “Fill in the form”步骤
                    if (TaskAPI.IsBeginStep)
                    {
                        mdc_spm_Formula_Change mdc_spm_Formula = new mdc_spm_Formula_Change();
                        if ((mdc_spm_Formula_Change.process == TaskAPI.Process & mdc_spm_Formula_Change.incident == TaskAPI.Incident & mdc_spm_Formula_Change.userName == UserAPI.UserName).Count<mdc_spm_Formula_Change>() > 0)
                        {
                            mdc_spm_Formula = (mdc_spm_Formula_Change.process == TaskAPI.Process & mdc_spm_Formula_Change.incident == TaskAPI.Incident & mdc_spm_Formula_Change.userName == UserAPI.UserName).ListFirst<mdc_spm_Formula_Change>();
                        }
                        else
                        {
                            mdc_spm_Formula.Process = TaskAPI.Process;
                            mdc_spm_Formula.Incident = TaskAPI.Incident;
                            mdc_spm_Formula.UserName = UserAPI.UserName;

                            mdc_spm_Formula.ApplicationNo = ApplicationNo.Text;
                            mdc_spm_Formula.Time = System.DateTime.Now;
                            mdc_spm_Formula.Status = 0;
                            mdc_spm_Formula.Department = UserAPI.Department;

                           
                        }
                        mdc_spm_Formula.DrpPriority = DrpPriority.SelectedValue;
                        (t_Attachment.process == TaskAPI.Process & t_Attachment.incident == 0 & t_Attachment.username == UserAPI.UserName).Edit<t_Attachment>(p =>
                        {
                            p.Incident = TaskAPI.Incident;
                        });
                        UsersChoose1.SaveStatus(Assessment1.Assessment.Opinion == "1" ? "1" : "0");
                        Storage.Save(Storage.Context1, mdc_spm_Formula);
                    }
                    #endregion

                    Save();

                    #region Priority功能
                    if (TaskAPI.IsBeginStep && !string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {
                        mdc_Priority pro;
                        if ((mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).Count<mdc_Priority>() > 0)
                        {
                            pro = new mdc_Priority();
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.Business_Priority = Convert.ToInt32(DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }
                        else
                        {
                            pro = new mdc_Priority();
                            pro.Process = TaskAPI.Process;
                            pro.Incident = TaskAPI.Incident;
                            pro.Business_Priority = Convert.ToInt32(DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }

                    }


                    if ((TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Approve" || TaskAPI.Step == "DMO Check") && !string.IsNullOrEmpty(this.DMO_DrpPriority.SelectedValue) && !string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {

                        //mdc_Priority pro;
                        //pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                        //pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                        //Storage.Save(pro);
                        mdc_Priority pro;
                        if ((mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).Count<mdc_Priority>() > 0)
                        {
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }
                        else
                        {
                            pro = (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == TaskAPI.Incident).ListFirst<mdc_Priority>();
                            pro.DMO_Priority = Convert.ToInt32(DMO_DrpPriority.SelectedValue);
                            Storage.Save(pro);
                        }


                    }
                    #endregion

                    #region “DMO Maintain”步骤
                    if (TaskAPI.Step == "DMO Maintain" || TaskAPI.Step == "DMO Approve" || TaskAPI.Step == "DMO Check")
                    {

                        TaskAPI["DMO_DrpPriority"] = DMO_DrpPriority.SelectedItem.Text;
                        (mdc_spm_Formula_Change.process == TaskAPI.Process & mdc_spm_Formula_Change.incident == TaskAPI.Incident).Edit<mdc_spm_Formula_Change>(p =>
                        {
                            // p.SAP_Code = SAP_Code.Text;
                            p.DMO_DrpPriority = DMO_DrpPriority.SelectedValue;

                        }
                        );
                    }
                    #endregion
 
                    Storage.Save(Assessment1.Assessment);    //审批意见
                    #region 退回步骤并返回功能 传值
                    if (TaskAPI["R_" + TaskAPI.Step.Replace(" ", "_").Replace("/", "_")] != null)
                    {
                        object[] obj = (object[])(TaskAPI["R_" + TaskAPI.Step.Replace(" ", "_").Replace("/", "_")]);
                        for (int i = 0; i < obj.GetUpperBound(0); i++)
                        {
                            obj[i] = null;
                        }
                        obj[0] = UserAPI.UserName;
                        TaskAPI["R_" + TaskAPI.Step.Replace(" ", "_")] = obj;
                    }
                    //多节点退回
                    if (!string.IsNullOrEmpty(Assessment1.JumpStep))
                    {
                        Assessment1.SetAsReturn(true);
                        TaskAPI.DirectActive(Assessment1.JumpStep);
                    }
                    else
                    {
                        Assessment1.SetAsReturn(false);
                    }
                    Assessment1.SubmitTo();
                   
                    #endregion
                    flg = TaskAPI.Send();
                });

                //如果数据库写入成功且流程发起成功的情况，将业务表数据与流程实例号进行关联
                if (TaskAPI.IsInitiate)
                {
                    if (!string.IsNullOrEmpty(DrpPriority.SelectedValue))
                    {
                        (mdc_Priority.process == TaskAPI.Process & mdc_Priority.incident == 0).Edit<mdc_Priority>(p =>
                        {
                            p.Incident = TaskAPI.Incident;
                        });
                    }
                    
                    (mdc_spm_Formula_Change.process == TaskAPI.Process & mdc_spm_Formula_Change.incident == 0 & mdc_spm_Formula_Change.userName == UserAPI.UserName).Edit<mdc_spm_Formula_Change>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });
                    (t_Assessment.process == TaskAPI.Process & t_Assessment.incident == 0 & t_Assessment.userName == UserAPI.UserName).Edit<t_Assessment>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });

                    (t_Attachment.process == TaskAPI.Process & t_Attachment.incident == 0 & t_Attachment.username == UserAPI.UserName).Edit<t_Attachment>(p =>
                    {
                        p.Incident = TaskAPI.Incident;
                    });


                }
                #endregion

                Send.Visible = false;
                Anthem.Manager.AddScriptForClientSideEval("JSInfomation('" + Resources.Global.C_00_Success + "',true)");
            }
            catch (Exception ex)
            {
                TaskDB.Log("", false, "调用NVA方法Send_Click出错：" + ex.ToString());
                Anthem.Manager.AddScriptForClientSideEval("JSInfomation('" + Resources.Global.C_00_Failed + "',false)");
            }

        }
        #endregion

        #region 方法 Save(保存数据库)
        public void Save()
        {
            //if (!Status.IsEdited)
            //{
            //    return;
            //}
            foreach (mdc_spm_Formula_Change mdc_spm_Formula in (List<mdc_spm_Formula_Change>)this.gv_Formula_Change.DataSource)
            {
                if (string.IsNullOrEmpty(mdc_spm_Formula.Fini_Sap_Code) || string.IsNullOrEmpty(mdc_spm_Formula.Plant) || string.IsNullOrEmpty(mdc_spm_Formula.New_Fini_Sap_Code) || string.IsNullOrEmpty(mdc_spm_Formula.Density))
                {
                   continue;
                }
 
                if (TaskAPI.IsBeginStep)
                {
                    mdc_spm_Formula.Process = TaskAPI.Process;
                    mdc_spm_Formula.Incident = TaskAPI.Incident;
                    mdc_spm_Formula.UserName = UserAPI.UserName;
                    mdc_spm_Formula.ApplicationNo = ApplicationNo.Text;
                    mdc_spm_Formula.Department = UserAPI.Department;
                }
                mdc_spm_Formula.Time = System.DateTime.Now;
                mdc_spm_Formula.Status = 1;
                Storage.Save(mdc_spm_Formula);
            }
        }
        #region 事件 Add(增加行)
        protected void Add_Click(object sender, EventArgs e)
        {
            switch (((Button)sender).ID)
            {
                case "Add":
                    List<mdc_spm_Formula_Change> mdc_spm_Formula_s = (List<mdc_spm_Formula_Change>)this.gv_Formula_Change.DataSource;
                    mdc_spm_Formula_Change mdc_spm_Formula = new mdc_spm_Formula_Change();
                    //sefi_1.ID = sefi_1_s.Count + 1;
                    mdc_spm_Formula_s.Insert(mdc_spm_Formula_s.Count, mdc_spm_Formula);
                    this.gv_Formula_Change.DataSource = mdc_spm_Formula_s;
                    gv_Formula_Change.DataBind();
                    break;
            }


        }
        #endregion
        #region 事件 Delete(删除行)
        protected void Delete_Click(object sender, EventArgs e)
        {
            switch (((Button)sender).ID)
            {
                case "Delete":
                    List<mdc_spm_Formula_Change> base_1_s = (List<mdc_spm_Formula_Change>)gv_Formula_Change.DataSource;
                    IList<mdc_spm_Formula_Change> base1 = (mdc_spm_Formula_Change.process == TaskAPI.Process & mdc_spm_Formula_Change.incident == TaskAPI.Incident).List<mdc_spm_Formula_Change>();
                    if (base_1_s.Count == 1)
                    {
                        Anthem.Manager.AddScriptForClientSideEval("JSInfomation('至少保留最后一个 Sheet ！',false)");
                        return;
                    }
                    base_1_s.RemoveAt(gv_Formula_Change.ChangedRowIndex == -1 || gv_Formula_Change.ChangedRowIndex >= base_1_s.Count ? base_1_s.Count - 1 : gv_Formula_Change.ChangedRowIndex);
                    bool flag = false;
                    foreach (mdc_spm_Formula_Change base_1 in base1)
                    {

                        foreach (mdc_spm_Formula_Change base_2 in base_1_s)
                        {
                            if (base_2.ID == base_1.ID)
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            Storage.Delete(base_1);
                        }
                        flag = false;
                    }
                    gv_Formula_Change.DataSource = base_1_s;
                    gv_Formula_Change.DataBind();
                    break;
            }
        }
        #endregion
        #region 方法 gv_Formula_Change 数据取得
        protected void gv_Formula_Change_DataBinding(object sender, EventArgs e)
        {
            //if (TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit && gv_CCC_1.ChangedColumnIndex == 9)
            //if (TaskAPI.IsBeginStep && TaskAPI.IsAllowSubmit && (gv_Sales_1.ChangedColumnIndex == 0 || gv_Sales_1.ChangedColumnIndex == 1))
            //H2.NET.Controls.GridView gv = (H2.NET.Controls.GridView)sender;
            //string id = gv.ID.ToString();
             
        }
        #endregion
        #endregion
        #region 方法 初始化Tabs
        protected void InitTabs()
        {
        }
        #endregion

       

       
        #region 方法 数据验证
        private List<string> DataValidation()
        {
            #region
            List<Regular> regs = new List<Regular>();
            int i = 1;
            foreach (mdc_spm_Formula_Change mdc_spm_Formula in (List<mdc_spm_Formula_Change>)this.gv_Formula_Change.DataSource)
            {
                if (string.IsNullOrEmpty(mdc_spm_Formula.Fini_Sap_Code) && string.IsNullOrEmpty(mdc_spm_Formula.Plant) && string.IsNullOrEmpty(mdc_spm_Formula.New_Fini_Sap_Code) && string.IsNullOrEmpty(mdc_spm_Formula.Density))
                {
                    continue;
                }
                regs.Add(new Regular(RegularExp.NotEmpty, (mdc_spm_Formula.Fini_Sap_Code+"").Trim(),"行:"+i+"&nbsp;&nbsp;    Fini_Sap_Code 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, (mdc_spm_Formula.Plant + "").Trim(), "行:" + i + "&nbsp;&nbsp;    Plant 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, (mdc_spm_Formula.New_Fini_Sap_Code + "").Trim(), "行:" + i + "&nbsp;&nbsp;    New_Fini_Sap_Code 必填"));
                regs.Add(new Regular(RegularExp.NotEmpty, (mdc_spm_Formula.Density + "").Trim(), "行:" + i + "&nbsp;&nbsp; 类型 Density 必填"));
                i++;
            }
            if (i == 1)
            {
                t_Attachment list = (t_Attachment.process == TaskAPI.Process & t_Attachment.incident == TaskAPI.Incident).ListFirst<t_Attachment>();
                if (list == null)
                {
                    regs.Add(new Regular(RegularExp.NotEmpty, list, "&nbsp;&nbsp;" + "表单不能为空或者必须上传附件!"));
                }

            }
            
            #endregion



            return Validation(regs);
        }
        #endregion

        #region 方法 Others
        protected void VD_Payment_Methods_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        private string getFormCheckList(Anthem.CheckBoxList ck)
        {
            string t = "";
            for (int i = 0; i < ck.Items.Count; i++)
                if (ck.Items[i].Selected)
                    t += "," + ck.Items[i].Value;
                else
                    t += ",";
            return t;
        }
        private Anthem.CheckBoxList setCheckList(string t, Anthem.CheckBoxList ck)
        {
            try
            {
                string[] tt = t.Split(',');

                for (int i = 0; i <= tt.GetUpperBound(0); i++)
                {
                    for (int j = 0; j < ck.Items.Count; j++)
                    {
                        if (ck.Items[j].Value == tt[i].ToString())
                        { ck.Items[j].Selected = true; break; }
                    }
                }
            }
            catch { }
            return ck;
        }
        #endregion


    }
}